package com.shenghua.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Administrator on 2019/4/11.
 */
public class DateUtil {
    private static Logger logger = LoggerFactory.getLogger(DateUtil.class);

    public static Date parseToDate(String time) {
        long l = Long.parseLong(time);
        Date date = new Date(l);
        return date;
    }

    public static String convertToStr(Date date) {
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
        String result = sdf.format(date);
        logger.info("parseYYYYMMDDHHmmss date:{}" , result);
        return result;
    }

    public static String getCurrentDate() {
        Date date = new Date();
        return convertToStr(date);
    }

    public static void main(String[] args){
        System.out.println(parseToDate("1553680436000"));
        System.out.println(convertToStr(new Date()));
    }
}
